<?php
session_start();
include('../includes/config.inc.php');
include('../lang/phrases.php');
include('../includes/functions.inc.php');
include('../lib/Connexion.class.php');
include('../lib/Contact.class.php');
include('../lib/Label.class.php');
include('../lib/Champ.class.php');

// Sécurité
if(!checkauth()) return;

if(!isset($_GET['id'])) return;
else $id = $_GET['id'];


$contact = new Contact();
$contact->load($id);
$data = $contact->vCard();

$nom = $contact->get("nom");
$prenom = $contact->get("prenom");

utf8_encode($data);

// Journalisation
appendlog("log_exportvcard");

/* Définition des header() PHP: le navigateur affiche un dialog de sauvegarde, mais pas cette page*/
header("Content-Type: application/csv-tab-delimited-table; charset=UTF-8");
header("Content-Disposition: attachment; filename=$prenom $nom.vcf");
header("Content-Encoding: UTF-8");
header("Pragma: no-cache");
header("Expires: 0");
print "$data";


?>